A class is the fundamental element of Java systems. They provide functions that support application programs and other programs that are written by developers. The classes, which may number in the thousands, reside in class files, which essentially are groupings of classes in containers. The containers may take a number of forms, typically including file system directories, archive files such as ZIP and JAR files, and in the case of Microsoft Corporation's Java VM implementation, they may also appear in a database of installed classes referred to as a Java Package Manager, which manages many attributes about the classes such as version, security and others. Any combination of these containers of classes, referred to as class path elements, can be put together in an order dependent list, known as the class path.
A class path is defined by use of an environment variable called ClassPath. ClassPath is used to define the order and places to search for classes when in an execution environment and in development environments. A class locator service, known as WS, or the Java Package Service, exposes an API which describes the class path as a single class source, with methods such as FindClass and EnumClasses regardless of the current configuration of the class path. These methods final all classes with a given name in all or a specified package, and enumerate all classes of given name respectively. However, they currently search through all the classes identified by the class path. When a JPS instance is created, it is initialized with a list of class path elements. For each element, a root object is created which represents the contents of the element. This object exposes an interface called IRoot, which has simple class location/enumeration methods, such as DoesClassExist, GetClass, and EnumClasses, each of which do what their names imply. Depending on the type of the element, a different implementation of a root object is created. For directory elements, a direct root object is created, whose IRoot method implementations result in direct searches of the root's underlying file system directory. For other elements, a root implementation that performs caching is created.
Since there are literally thousands of classes available for use when developing applications, it can be difficult to keep track of them. Further, many different containers are available from different companies or other organizations to support programming in Java. Each of the different containers may have classes with similar names and similar functions. In a development environment, it is necessary for a class location system to provide a list of all the existing classes to help the developer select a desired class for use. When a developer is writing or modifying an application, the list can be useful to help the developer determine which class to select.
There are three significant differences in the way that a class locator service is utilized in the development environment as opposed to the execution environment. First, the Java compiler must verify that classes do not appear in certain locations, and therefore must make requests for classes that probably do not exist. Second, the development environment must provide lists of all available classes in given packages, where a package is an organized sub-container of classes. These classes are referred to by their package name plus their class name. And, finally, the development environment needs to inspect a small portion of each class found to provide and display more detailed information about the class, such as its fields, methods and attributes.
Each of these three differences place a different efficiency requirement on the class locator. First, unsuccessful searches are speed critical. Second, fast enumeration of all classes is required. Third, the interesting information about a class must be easily and quickly obtainable from each class located. There is a need for a class location mechanism that can find classes in a fast and efficient manner. There is a further need for such a mechanism that operates with existing development environments.